{include file="public/layout" /}

{eq name="$editor.editor_select" value="1"}
    {load href="__PUBLIC__/plugins/Ueditor/ueditor.config.js" /}
    {load href="__PUBLIC__/plugins/Ueditor/ueditor.all.min.js" /}
    {load href="__PUBLIC__/plugins/Ueditor/lang/zh-cn/zh-cn.js" /}
{else/}
    {load href="__PUBLIC__/plugins/ckeditor/ckeditor.js" /}
{/eq}

<body style="overflow: auto; cursor: default; -moz-user-select: inherit;background-color:#F4F4F4; ">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="shop/left" /}
<div id="geduan_div" class="h15"></div>
<div id="page_div" class="page min-hg-c mb-20" style="min-width:auto;box-shadow:none;">
    <div class="flexigrid">
        <div class="fixed-bar">
            <div class="item-title">
                <a class="back_xin" href="javascript:history.back();" title="返回"><i class="iconfont e-fanhui"></i></a>
                <a class="back_sz" href="javascript:void(0);"  data-href="{:url('ShopProduct/help')}" onclick="openHelpframe(this, '设置与帮助', '500px', '100%', 'r');" title="设置与帮助"><i class="iconfont e-shezhi-tongyong"></i></a>
                <div class="subject">
                    <h3>发布商品</h3>
                    <h5></h5>
                </div>
                <ul class="tab-base nc-row">
                    <li><a href="javascript:void(0);" data-index='1' class="tab current"><span>基础内容</span></a></li>
                    <li><a href="javascript:void(0);" data-index='2' class="tab"><span>商品参数</span></a></li>
                    <li><a href="javascript:void(0);" data-index='3' class="tab"><span>SEO优化</span></a></li>
                    <li><a href="javascript:void(0);" data-index='4' class="tab"><span>更多设置</span></a></li>
                </ul>
            </div>
        </div>
        <form class="form-horizontal" id="post_form" action="{:url('ShopProduct/add')}" method="post">
            <!-- 常规信息 -->
            <div class="ncap-form-default tab_div_1">
                <dl class="row">
                    <dt class="tit"> <label for="title"><em>*</em>商品标题</label> </dt>
                    <dd class="opt">
                        <input type="text" name="title" id="title" class="input-txt" maxlength="200" {eq name="$channelRow.is_repeat_title" value="0"} oninput="check_title_repeat(this, 0);" {/eq}>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        副标题：<input type="text" name="subtitle" id="subtitle" class="w200">
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label><em>*</em>栏目分类</label> </dt>
                    <dd class="opt">
                        <select name="typeid" id="typeid">
                            <option value="0">请选择栏目…</option>
                            {$arctype_html}
                        </select>
                    </dd>
                </dl>
                <dl class="row {empty name='$global.web_stypeid_open'} none {/empty}">
                    <dt class="tit"> <label for="stypeid">副栏目分类</label> </dt>
                    <dd class="opt"> 
                        <input type="hidden" name="stypeid" id="stypeid" class="input-txt" onkeyup="this.value=this.value.replace(/[^\d\,]/g,'');" onpaste="this.value=this.value.replace(/[^\d\,]/g,'');">
                        &nbsp;<a href="javascript:void(0);" data-channel="{$channeltype}" onclick="select_stypeid(this);" class="ncap-btn ncap-btn-green">选择副栏目</a>
                        <div id="stypeid_txt" class="pt5"></div>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label>商品属性</label> </dt>
                    <dd class="opt">
                        <label><input type="checkbox" name="is_head" value="1">头条</label>&nbsp;
                        <label><input type="checkbox" name="is_recom" value="1">推荐</label>&nbsp;
                        <label><input type="checkbox" name="is_special" value="1">特荐</label>&nbsp;
                        <label><input type="checkbox" name="is_b" value="1">加粗</label>&nbsp;
                        <label><input type="checkbox" name="is_litpic" value="1">图片</label>&nbsp;
                        <label><input type="checkbox" name="is_jump" value="1">跳转</label>&nbsp;
                    <span class="err"></span>
                    <p class="notic">如需管理，请点击右上角设置与帮助按钮</p>
                    </dd>
                </dl>
                <dl class="row none dl_jump">
                    <dt class="tit"> <label for="jumplinks">跳转网址</label> </dt>
                    <dd class="opt">
                        <input type="text" name="jumplinks" id="jumplinks" class="input-txt" placeholder="http://">
                    </dd>
                </dl>
                <dl class="row" style="z-index: 2;">
                    <dt class="tit"> <label>商品标签</label> </dt>
                    <dd class="opt">          
                        <input type="text" name="tags" id="tags" class="input-txt" placeholder="多个标签之间以逗号隔开" autocomplete="off" oninput="get_common_tagindex_input(this);" onfocus="$('#often_tags').hide();" onkeyup="this.value=this.value.replace(/[\，]/g,',');" onpaste="this.value=this.value.replace(/[\，]/g,',');">&nbsp;
                        <a href="javascript:void(0);" onclick="get_common_tagindex(this);">显示常用标签</a>&nbsp;<img id="tag_loading" src="__STATIC__/common/images/loading.gif" style="display: none;" />
                        <div class="often_tags" id="often_tags" data-opt="add" style="display: none;"></div>
                        <div class="often_tags" id="often_tags_input" style="display: none;"></div>
                        <input type="hidden" id="tags_click_count">
                    </dd>
                </dl>
                <dl class="row {empty name='$global.web_citysite_open'} none {/empty} ">
                    <dt class="tit"> <label>所属区域</label> </dt>
                    <dd class="opt"> 
                        <select name="province_id" id="province_id" onchange="set_city_list(0);">
                            <option value="0">全国</option>
                            {volist name=':get_site_province_list()' id='vo'}
                            <option value="{$vo.id}" {eq name="$Request.param.province_id" value="$vo.id" } selected="true" {/eq}>{$vo.name}</option>
                            {/volist}
                        </select>
                        <select name="city_id" id="city_id" class="none ml5" onchange="set_area_list(0);">
                            <option value="">--请选择--</option>
                        </select>
                        <select name="area_id" id="area_id" class="none ml5">
                            <option value="">--请选择--</option>
                        </select>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label>封面图片</label> </dt>
                    <dd class="opt">
                        <div class="input-file-show div_litpic_local">
                            <span class="show">
                                <a id="img_a" target="_blank" class="nyroModal" rel="gal" href="javascript:void(0);">
                                    <i id="img_i" class="fa fa-picture-o" onmouseover="" onmouseout="layer.close(layer_tips);"></i>
                                </a>
                            </span>
                            <span class="type-file-box">
                                <input type="text" id="litpic_local" name="litpic_local" class="type-file-text" autocomplete="off">
                                <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                                <input class="type-file-file" onClick="GetUploadify(1,'','allimg','img_call_back')" size="30" hidefocus="true" nc_type="change_site_logo" title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
                            </span>
                        </div>
                        <input type="text" id="litpic_remote" name="litpic_remote" placeholder="http://" class="input-txt" onKeyup="keyupRemote(this, 'litpic');" style="display: none;">
                        &nbsp;
                        <label><input type="checkbox" name="is_remote" id="is_remote" value="1" onClick="clickRemote(this, 'litpic');">远程图片</label>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label>图片集</label> </dt>
                    <dd class="opt">
                        <div class="tab-pane pics" id="tab_proimg">
                            <table class="table table-bordered">
                                <tbody>
                                    <tr>
                                        <td>
                                            <div class="sort-list-img"> <div class="images_upload"></div> </div>
                                            <a href="javascript:void(0);" onClick="GetUploadify(30,'','allimg','proimg_call_back');" class="img-upload mb15" title="点击上传"> <div class="y-line"></div> <div class="x-line"></div> </a>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <!-- 上传图片显示的样板 start -->
                        <div class="images_upload_tpl none">
                            <div class="images_upload images_upload_html">
                                <div style="position: relative; height: 130px;">
                                    <input type="hidden" name="proimg[]" />
                                    <a href="javascript:void(0);" onClick="" class="upimg" title="拖动修改排序">
                                        <img src="__STATIC__/admin/images/add-button.jpg" width="136" height="136" />
                                    </a>
                                    <a href="javascript:void(0)" class="delect" title="删除">&nbsp;&nbsp;</a>
                                </div>
                                <textarea rows="5" cols="60" name="imgintro[]" style="height:28px; width: 136px;" placeholder="图片注释"></textarea>
                            </div>
                        </div>
                        <!-- 上传图片显示的样板 end -->
                    </dd>
                </dl>
        
                {if condition="!empty($shopConfig['shop_open']) && 1 == $shopConfig['shop_open']"}
                    {empty name="$shopConfig['shop_type']"}<input type="hidden" name="prom_type" value="0"/>{/empty}

                    {eq name="$shopConfig['shop_type']" value="1"}
                        <input type="hidden" name="prom_type" value="1"/>
                        <dl class="row" id="fahuoxingshi" >
                            <dt class="tit"> <label for="fahuo">发货形式</label> </dt>
                            <dd class="opt">
                                <label> <input type="radio" name="prom_type_vir" value="1" onclick="change_prom_type(2)" checked="checked" />手动发货 </label>
                                &nbsp;
                                <label> <input type="radio" name="prom_type_vir" value="2" onclick="change_prom_type(3)"/>网盘下载 </label>
                                &nbsp;
                                <label> <input type="radio" name="prom_type_vir" value="3" onclick="change_prom_type(4)"/>文本内容 </label>
                            </dd>
                        </dl>
                        <div id="wangpanxiazai" class="none">
                            <dl class="row">
                                <dt class="tit"> <label for="netdisk_url"><em>*</em>网盘地址</label> </dt>
                                <dd class="opt">
                                    <input type="text" name="netdisk_url" id="netdisk_url" class="input-txt" placeholder="http://">
                                </dd>
                            </dl>
                            <dl class="row">
                                <dt class="tit"> <label for="netdisk_pwd">提取码</label> </dt>
                                <dd class="opt"> <input type="text" name="netdisk_pwd" id="netdisk_pwd" class="input-txt"> </dd>
                            </dl>
                            <dl class="row">
                                <dt class="tit"> <label for="unzip_pwd">解压密码</label> </dt>
                                <dd class="opt"> <input type="text" name="unzip_pwd" id="unzip_pwd" class="input-txt"> </dd>
                            </dl>
                        </div>
                        <dl class="row none" id="wenbenneirong">
                            <dt class="tit"> <label for="text_content"><em>*</em>文本内容</label> </dt>
                            <dd class="opt">
                                <textarea rows="5" cols="80" id="text_content" name="text_content" style="width: 375px; height: 160px;"></textarea>
                            </dd>
                        </dl>
                    {/eq}

                    {eq name="$shopConfig['shop_type']" value="2"}
                        <!-- 两者都有 -->
                        <dl class="row">
                            <dt class="tit"> <label>产品类型</label> </dt>
                            <dd class="opt">
                                <label> <input type="radio" name="prom_type" value="0" onclick="change_prom_type(0)" checked="checked"/>普通产品 </label>
                                &nbsp;
                                <label> <input type="radio" name="prom_type" value="1" onclick="change_prom_type(1)"/>虚拟产品 </label>
                            </dd>
                        </dl>
                        <dl class="row none" id="fahuoxingshi">
                            <dt class="tit"> <label for="fahuo">发货形式</label> </dt>
                            <dd class="opt">
                                <label> <input type="radio" name="prom_type_vir" value="1" onclick="change_prom_type(2)" checked="checked"/>手动发货 </label>
                                &nbsp;
                                <label> <input type="radio" name="prom_type_vir" value="2" onclick="change_prom_type(3)"/>网盘下载 </label>
                                &nbsp;
                                <label> <input type="radio" name="prom_type_vir" value="3" onclick="change_prom_type(4)"/>文本内容 </label>
                            </dd>
                        </dl>
                        <div id="wangpanxiazai" class="none">
                            <dl class="row">
                                <dt class="tit"> <label for="netdisk_url"><em>*</em>网盘地址</label> </dt>
                                <dd class="opt">
                                    <input type="text" name="netdisk_url" id="netdisk_url" class="input-txt" placeholder="http://">
                                </dd>
                            </dl>
                            <dl class="row">
                                <dt class="tit"> <label for="netdisk_pwd">提取码</label> </dt>
                                <dd class="opt"> <input type="text" name="netdisk_pwd" id="netdisk_pwd" class="input-txt"> </dd>
                            </dl>
                            <dl class="row">
                                <dt class="tit"> <label for="unzip_pwd">解压密码</label> </dt>
                                <dd class="opt"> <input type="text" name="unzip_pwd" id="unzip_pwd" class="input-txt"> </dd>
                            </dl>
                        </div>
                        <dl class="row none" id="wenbenneirong">
                            <dt class="tit"> <label for="text_content"><em>*</em>文本内容</label> </dt>
                            <dd class="opt">
                                <textarea rows="5" cols="80" id="text_content" name="text_content" style="width: 375px; height: 160px;"></textarea>
                            </dd>
                        </dl>
                    {/eq}
                {/if}
                    
                {if condition="1 == $shopConfig['shop_open'] && !empty($ifcontrolRow['users_price'])"}
                    {if condition="!isset($shopConfig['shop_open_spec']) || 0 == $shopConfig['shop_open_spec']"}
                        <!-- 待添加后续逻辑... -->
                    {else/}
                        <dl class="row">
                            <dt class="tit"> <label>商品规格</label> </dt>
                            <dd class="opt">
                                <label><input type="radio" id="spec_type1" name="spec_type" value="1" checked="checked" onclick="SpecTypeSelect(1);">单规格</label>&nbsp;
                                <label><input type="radio" id="spec_type2" name="spec_type" value="2" onclick="SpecTypeSelect(2);">多规格</label>
                            </dd>
                        </dl>
                        <dl class="row spec_type_2" style="display: none;">
                            <dt class="tit"> <label for="users_price"></label> </dt>
                            <dd class="opt">
                                <div>
                                    <div id='SpecSelectName'></div>
                                    <input type="hidden" id="spec_mark_id_arr">
                                    <input type="hidden" id="maxPresetMarkID" value="{$maxPresetMarkID}">
                                    <div id="addSpecButton">
                                        <a href="JavaScript:void(0);" id="addCustomSpec" data-value="0" onclick="addCustomSpec(this);" class="ncap-btn ncap-btn-green ml15">新增规格</a>
                                        &nbsp; &nbsp; &nbsp;
                                        <select class="preset-select" name="spec_value" id="spec_value" onchange="addPresetSpec(this)">
                                            <option value="0">从规格库提取</option>
                                            {volist name="preset_value" id="vo"}
                                            <option value="{$vo.preset_mark_id}">{$vo.preset_name}</option>
                                            {/volist}
                                        </select>
                                    </div><br/>
                                </div>
                            </dd>
                        </dl>
                        <dl class="row spec_type_2" style="display: none;">
                            <dt class="tit"> <label for="users_price">价格/库存</label> </dt>
                            <dd class="opt"> <div id='SpecTempLateDiv'></div> </dd>
                        </dl>
                    {/if}
                {/if}

                {if condition="!empty($ifcontrolRow['users_price'])"}
                    <dl class="row spec_type_1">
                        <dt class="tit"> <label for="users_price"> {if condition="1 == $shopConfig['shop_open']"}<em>*</em>{/if}价格 </label> </dt>
                        <dd class="opt">
                            <input type="text" name="users_price" id="users_price" style="width: 10%;" placeholder="原价" onkeyup="this.value=this.value.replace(/[^\.\d]/g,'');" onpaste="this.value=this.value.replace(/[^\.\d]/g,'');">
                        </dd>
                    </dl>
                {/if}

                {if condition="1 == $shopConfig['shop_open'] && !empty($ifcontrolRow['users_price'])"}
                    <dl class="row spec_type_1">
                        <dt class="tit"> <label for="stock_count">库存</label> </dt>
                        <dd class="opt">
                            <input type="text" name="stock_count" id="stock_count" style="width: 10%;" value="99999">
                            <label> <input type="checkbox" name="stock_show" value="1" checked="checked"> 页面显示商品库存 </label>
                        </dd>
                    </dl>
                    {if condition="!isset($shopConfig['shop_open_spec']) || 0 == $shopConfig['shop_open_spec']"}
                        <!-- 待添加后续逻辑... -->
                    {else /}
                        <script type="text/javascript">
                            function SpecTypeSelect(spec_type) {
                                var IsSpecData = $('#SpecTempLateDiv').html();
                                if (1 == spec_type) {
                                    $('.spec_type_1').show();
                                    $('.spec_type_2').hide();
                                    $('#users_price, #stock_count').removeAttr("readonly");
                                    if (IsSpecData && IsSpecData != ' ') {
                                        layer.confirm('<span style="color: red;">请注意：您已添加多规格，若切换单规格并保存商品，则清空多规格数据！</span>', {
                                            shade: layer_shade,
                                            area: ['480px', '190px'],
                                            move: false,
                                            title: '提示',
                                            btnAlign:'r',
                                            closeBtn: 3,
                                            btn: ['确定', '取消'] ,//按钮
                                            success: function () {
                                                  $(".layui-layer-content").css('text-align', 'left');
                                              }
                                        }, function (index) {
                                            $('#spec_type1').attr('checked', 'checked');
                                            $('#spec_type2').removeAttr('checked');
                                            layer.close(index);
                                        }, function (index) {
                                            $('.spec_type_1').hide();
                                            $('.spec_type_2').show();
                                            $('#users_price, #stock_count').attr("readonly", "readonly");
                                            $('#spec_type1').removeAttr('checked');
                                            $('#spec_type2').attr('checked', 'checked');
                                            layer.close(index);
                                        });
                                    }
                                } else {
                                    $('.spec_type_1').hide();
                                    $('.spec_type_2').show();
                                    $('#users_price, #stock_count').attr("readonly", "readonly");
                                }
                            }
                        </script>

                        <script type="text/javascript">
                            // 规格列表管理
                            var TemplateUrl = "{:url('Shop/spec_template')}";
                            // 规格选择
                            var SelectUrl = "{:url('Shop/spec_select')}";
                            // 获取规格名称规格值框架URL
                            var GetHtmlUrl = "{:url('Shop/assemble_spec_data')}";
                            // 当规格库更新后，调用此方式及时更新从规格库提取的下拉框信息
                            var GetPresetSpecUrl = "{:url('Shop/update_spec_info')}";
                            // 同步更新规格库数据到产品规格中，单条操作
                            var RefreshPresetUrl = "{:url('Shop/refresh_preset_value')}";

                            // 初始化规格，清除多余规格数据
                            AjaxInitializationSpec();
                            function AjaxInitializationSpec() {
                                $.ajax({
                                    type: 'post',
                                    url : GetHtmlUrl,
                                    data: {initialization: true, _ajax: 1},
                                    dataType : 'json',
                                });
                            }

                            // 自定增加一个自定义规格
                            $('#addCustomSpec').click();
                            // 自定义规格
                            function addCustomSpec(obj) {
                                // 本次使用的规格数量
                                var specValue = $(obj).attr('data-value');
                                if (3 <= specValue) {
                                    showErrorMsg('最多使用三种商品规格大类');
                                    return false;
                                }
                                // 自定义规格数量+1覆盖原值
                                $(obj).attr('data-value', ++specValue);
                                // if (3 == specValue) $('#addSpecButton').hide();
                                // 创建一个自定义规格空数据和表格
                                layer_loading('正在处理');
                                $.ajax({
                                    type: 'post',
                                    data: {action: 'name', _ajax: 1},
                                    url : "{:url('ShopProduct/add_product_custom_spec')}",
                                    dataType: 'json',
                                    success: function(res) {
                                        layer.closeAll();
                                        if (1 == res.code) {
                                            // 最大的规格标记ID
                                            var maxSpecMarkID = res.data.spec_mark_id;
                                            // 规格框
                                            var html = [
                                                '<div class="prset-box">'+
                                                    '<span class="set-preset-bt mr10" style="display: block;">'+
                                                        '<input type="text" name="set_spec_name" class="zdy-ggname w150" placeholder="规格名称.." onchange="setSpecName(this, ' + maxSpecMarkID + ');">'+
                                                        '<em onclick="setSpecNameClear(this, ' + maxSpecMarkID + ');">'+
                                                            '<i class="fa fa-times-circle" title="关闭" style="margin-left: -20px; margin-top: 8px;"></i>'+
                                                        '</em>'+
                                                    '</span>'+
                                                    '<span class="set-preset-box"></span>'+
                                                    '<span class="set-preset-con">'+
                                                        '<span class="set-preset-bt mr10">'+
                                                            '<input type="hidden" value="' + res.data.spec_value_id + '">'+
                                                            '<input type="text" class="zdy-ggshuzi w150" placeholder="规格值.." onchange="setSpecValue(this, ' + maxSpecMarkID + ');">'+
                                                        '</span>'+
                                                        '<a href="javascript:void(0);" onclick="addCustomSpecValue(this, ' + maxSpecMarkID + ');" class="preset-bt-shuzi mr10">+增加规格值</a>'+
                                                    '</span>'+
                                                '</div>'
                                            ];
                                            $('#SpecSelectName').show().append(html);
                                            // 价格/库存HTML
                                            if (res.data.htmlTable) {
                                                // 加载规格框架
                                                $('#SpecTempLateDiv').html(res.data.htmlTable);
                                                // 合并单元格
                                                MergeCells();
                                            }
                                        } else {
                                            showErrorMsg(res.msg, 2);
                                        }
                                    },
                                    error: function(e) {
                                        layer.closeAll();
                                        showErrorAlert(e.responseText);
                                    }
                                });
                            }

                            // 输入完规格名称后执行
                            function setSpecName(obj, spec_mark_id) {
                                var set_spec_name = $(obj).val();
                                if (spec_mark_id && set_spec_name) {
                                    $.ajax({
                                        type: 'post',
                                        dataType: 'json',
                                        data: {spec_mark_id: spec_mark_id, set_spec_name: set_spec_name},
                                        url : "{:url('ShopProduct/add_product_custom_spec_name', ['_ajax'=>1])}",
                                        success: function(res) {
                                            if (1 == res.code) {
                                                // 价格/库存HTML
                                                if (res.data.htmlTable) {
                                                    // 加载规格框架
                                                    $('#SpecTempLateDiv').html(res.data.htmlTable);
                                                    // 合并单元格
                                                    MergeCells();
                                                }
                                            } else {
                                                showErrorMsg(res.msg, 2);
                                            }
                                        },
                                        error: function(e) {
                                            layer.closeAll();
                                            showErrorAlert(e.responseText);
                                        }
                                    });
                                }
                            }

                            // 清除数据库指定数据
                            function setSpecNameClear(obj, spec_mark_id) {
                                if (spec_mark_id) {
                                    // 执行处理
                                    $.ajax({
                                        type: 'post',
                                        url : "{:url('ShopProduct/del_product_custom_spec', ['_ajax'=>1])}",
                                        data: {spec_mark_id: spec_mark_id, del: 'name'},
                                        dataType: 'json',
                                        success: function(res) {
                                            // 删除当前点击规格块的顶级html
                                            $(obj).parent().parent().remove();
                                            // 如果存在则执行覆盖新的规格列表框
                                            if (res.data.htmlTable) {
                                                // 加载规格框架
                                                $('#SpecTempLateDiv').html(res.data.htmlTable);
                                                // 合并单元格
                                                MergeCells();
                                            }
                                            // 使用规格数量+1覆盖原值
                                            var specValue = $('#addCustomSpec').attr('data-value');
                                            $('#addCustomSpec').attr('data-value', --specValue);
                                            // 显示添加按钮
                                            // $('#addSpecButton').show();
                                        }
                                    });
                                }
                            }

                            // 规格规格值
                            function addCustomSpecValue(obj, spec_mark_id) {
                                if (spec_mark_id) {
                                    layer_loading('正在处理');
                                    $.ajax({
                                        type: 'post',
                                        data: {spec_mark_id: spec_mark_id, action: 'value', _ajax: 1},
                                        url : "{:url('ShopProduct/add_product_custom_spec')}",
                                        dataType: 'json',
                                        success: function(res) {
                                            layer.closeAll();
                                            if (1 == res.code) {
                                                // 规格值HTML
                                                var html = [
                                                    '<span class="set-preset-bt mr10">'+
                                                        '<input type="hidden" value="' + res.data.spec_value_id + '">'+
                                                        '<input type="text" class="zdy-ggshuzi w150" placeholder="规格值.." onchange="setSpecValue(this, ' + res.data.spec_mark_id + ');">'+
                                                        '<em data-spec_mark_id="' + res.data.spec_mark_id + '" data-spec_value_id="' + res.data.spec_value_id + '" onclick="setSpecValueClear(this);"><i class="fa fa-times-circle" title="关闭" style="margin-left: -22px;margin-top: 8px;cursor: pointer;"></i></em>'+
                                                    '</span>'
                                                ];
                                                // 加载一个规格值 input
                                                $(obj).before(html);
                                                // 价格/库存HTML
                                                if (res.data.htmlTable) {
                                                    // 加载规格框架
                                                    $('#SpecTempLateDiv').html(res.data.htmlTable);
                                                    // 合并单元格
                                                    MergeCells();
                                                }
                                            } else {
                                                showErrorMsg(res.msg, 2);
                                            }
                                        },
                                        error: function(e) {
                                            layer.closeAll();
                                            showErrorAlert(e.responseText);
                                        }
                                    });
                                }
                            }

                            // 输入完规格值后执行
                            function setSpecValue(obj, spec_mark_id) {
                                // 指定的FormID
                                var set_spec_value = $(obj).val();
                                var spec_value_id = $(obj).prev().val();
                                if (set_spec_value && spec_value_id && spec_mark_id) {
                                    $.ajax({
                                        type: 'post',
                                        dataType: 'json',
                                        data: {set_spec_value: set_spec_value, spec_value_id: spec_value_id, spec_mark_id: spec_mark_id},
                                        url : "{:url('ShopProduct/add_product_custom_spec_value', ['_ajax'=>1])}",
                                        success: function(res) {
                                            if (1 == res.code) {
                                                // 价格/库存HTML
                                                if (res.data.htmlTable) {
                                                    // 加载规格框架
                                                    $('#SpecTempLateDiv').html(res.data.htmlTable);
                                                    // 合并单元格
                                                    MergeCells();
                                                }
                                            } else {
                                                showErrorMsg(res.msg, 2);
                                            }
                                        },
                                        error: function(e) {
                                            layer.closeAll();
                                            showErrorAlert(e.responseText);
                                        }
                                    });
                                }
                            }

                            // 清除数据库指定数据
                            function setSpecValueClear(obj) {
                                // 当选对象
                                var spec_mark_id = $(obj).attr('data-spec_mark_id');
                                var spec_value_id = $(obj).attr('data-spec_value_id');
                                // 执行处理
                                $.ajax({
                                    type: 'post',
                                    url : "{:url('ShopProduct/del_product_custom_spec', ['_ajax'=>1])}",
                                    data: {spec_mark_id: spec_mark_id, spec_value_id: spec_value_id, del: 'value'},
                                    dataType: 'json',
                                    success: function(res) {
                                        // 删除当前点击规格块的顶级html
                                        $(obj).parent().remove();
                                        // 如果存在则执行覆盖新的规格列表框
                                        if (res.data.htmlTable) {
                                            // 加载规格框架
                                            $('#SpecTempLateDiv').html(res.data.htmlTable);
                                            // 合并单元格
                                            MergeCells();
                                        }
                                    }
                                });
                            }

                            // 规格库删除规格值时，同步更新页面上的规格信息
                            function RefreshPresetValue(preset_id, preset_mark_id) {
                                $.ajax({
                                    type : 'post',
                                    url  : RefreshPresetUrl,
                                    data : {preset_id:preset_id, preset_mark_id:preset_mark_id, _ajax:1},
                                    dataType : 'json',
                                    success : function(res){
                                        if (1 == res.code) {
                                            // 删除规格值
                                            $('#preset-bt2_'+preset_id).remove();
                                            if (res.data.DelAllPreset) {
                                                // 删除整个规格名称
                                                $('#preset_'+preset_mark_id).remove();
                                            }
                                            if (res.data.HtmlTable) {
                                                // 加载规格框架
                                                $('#SpecTempLateDiv').html(res.data.HtmlTable);
                                                // 合并单元格
                                                MergeCells();
                                            }
                                        }
                                    },
                                    error : function(e) {
                                        layer.closeAll();
                                        layer.alert(e.responseText, {icon: 5});
                                    }
                                });
                            }

                            // 生成选中规格名称html并更新加载规格值
                            function addPresetSpec(obj) {
                                var preset_mark_id = $(obj).val();
                                if (0 === parseInt(preset_mark_id)) return false;
                                // 本次使用的规格数量
                                var specValue = $('#addCustomSpec').attr('data-value');
                                if (3 <= specValue) {
                                    showErrorMsg('最多使用三种商品规格大类');
                                    return false;
                                }
                                // 自定义规格数量+1覆盖原值
                                $('#addCustomSpec').attr('data-value', ++specValue);
                                // if (3 == specValue) $('#addSpecButton').hide();
                                layer_loading('正在处理');
                                $.ajax({
                                    type: 'post',
                                    url : "{:url('ShopProduct/add_product_custom_spec')}",
                                    data: {preset_mark_id: preset_mark_id, action: 'specName', _ajax: 1},
                                    dataType: 'json',
                                    success: function(res) {
                                        layer.closeAll();
                                        if (0 == res.code) {
                                            showErrorMsg(res.msg);
                                        } else {
                                            // 主DIV加载
                                            var html = [
                                                '<div class="prset-box" id="preset_'+preset_mark_id+'">'+
                                                    '<div id="div_'+preset_mark_id+'">'+
                                                        '<div><span class="preset-bt w150 mr10" style="display: block;"><span class="spec_name_span_'+preset_mark_id+'">'+res.data.spec_name+'</span><em data-name="'+res.data.spec_name+'" data-mark_id="'+preset_mark_id+'" onclick="clearPresetSpec(this, '+preset_mark_id+')"><i class="fa fa-times-circle" title="关闭"></i></em></span>'+
                                                            '<span class="set-preset-box"></span>'+
                                                            '<span class="set-preset-con">'+
                                                                '<span id="SelectEd_'+preset_mark_id+'"></span>'+
                                                                '<select class="preset-select" name="spec_value" id="spec_value_'+preset_mark_id+'" onchange="addPresetSpecValue(this, '+preset_mark_id+')">'+
                                                                '</select>'+
                                                            '</span>'+
                                                        '</div>'+
                                                    '</div>'+
                                                '</div>'
                                            ];
                                            $('#SpecSelectName').append(html);
                                            // 规格值加载
                                            if (res.data.spec_value_option) $('#spec_value_' + preset_mark_id).empty().html(res.data.spec_value_option);
                                            // 更新预设名称下拉框
                                            if (res.data.preset_name_option) $('#spec_value').empty().html(res.data.preset_name_option);
                                            // 价格/库存HTML
                                            if (res.data.htmlTable) {
                                                // 加载规格框架
                                                $('#SpecTempLateDiv').html(res.data.htmlTable);
                                                // 合并单元格
                                                MergeCells();
                                            }
                                        }
                                    }
                                });
                            }

                            // 清除数据库指定数据
                            function clearPresetSpec(obj, spec_mark_id) {
                                if (spec_mark_id) {
                                    // 执行处理
                                    $.ajax({
                                        type: 'post',
                                        url : "{:url('ShopProduct/del_product_custom_spec', ['_ajax'=>1])}",
                                        data: {spec_mark_id: spec_mark_id, del: 'specName'},
                                        dataType: 'json',
                                        success: function(res) {
                                            // 删除当前点击规格块的顶级html
                                            $(obj).parent().parent().parent().parent().remove();
                                            // 如果存在则执行覆盖新的规格列表框
                                            if (res.data.htmlTable) {
                                                // 加载规格框架
                                                $('#SpecTempLateDiv').html(res.data.htmlTable);
                                                // 合并单元格
                                                MergeCells();
                                            }
                                            // 更新预设名称下拉框
                                            if (res.data.preset_name_option) $('#spec_value').empty().html(res.data.preset_name_option);
                                            // 使用规格数量+1覆盖原值
                                            var specValue = $('#addCustomSpec').attr('data-value');
                                            $('#addCustomSpec').attr('data-value', --specValue);
                                            // 显示添加按钮
                                            // $('#addSpecButton').show();
                                        }
                                    });
                                }
                            }

                            // 追加预设规格名称和规格值
                            function addPresetSpecValue(obj, spec_mark_id) {
                                var spec_value_id = $(obj).val();
                                layer_loading('正在处理');
                                $.ajax({
                                    type: 'post',
                                    url : "{:url('ShopProduct/add_product_custom_spec')}",
                                    data: {spec_value_id: spec_value_id, spec_mark_id: spec_mark_id, action: 'specValue', _ajax: 1},
                                    dataType : 'json',
                                    success : function(res){
                                        layer.closeAll();
                                        if (0 == res.code) {
                                            showErrorMsg(res.msg);
                                        }else{
                                            // 追加选中的值
                                            $('#SelectEd_'+spec_mark_id).append(
                                                '<span class="preset-bt2 mr10" id="preset-bt2_'+spec_value_id+'"><span class="preset_value_span_'+spec_value_id+'">'+res.data.spec_value+'</span><em data-value="'+res.data.spec_value+'" data-spec_mark_id="'+spec_mark_id+'" data-spec_value_id="'+spec_value_id+'" onclick="clearPresetSpecValue(this)"><i class="fa fa-times-circle" title="关闭"></i></em> &nbsp; </span>'
                                            );
                                            // 规格值加载
                                            if (res.data.spec_value_option) $('#spec_value_'+spec_mark_id).empty().html(res.data.spec_value_option);
                                            // 价格/库存HTML
                                            if (res.data.htmlTable) {
                                                // 加载规格框架
                                                $('#SpecTempLateDiv').html(res.data.htmlTable);
                                                // 合并单元格
                                                MergeCells();
                                            }
                                        }
                                    }
                                });
                            }

                            // 清除数据库指定数据
                            function clearPresetSpecValue(obj) {
                                // 当选对象
                                var spec_mark_id = $(obj).attr('data-spec_mark_id');
                                var spec_value_id = $(obj).attr('data-spec_value_id');
                                // 执行处理
                                $.ajax({
                                    type: 'post',
                                    url : "{:url('ShopProduct/del_product_custom_spec', ['_ajax'=>1])}",
                                    data: {spec_mark_id: spec_mark_id, spec_value_id: spec_value_id, del: 'specValue'},
                                    dataType: 'json',
                                    success: function(res) {
                                        // 删除当前点击规格块的顶级html
                                        $(obj).parent().remove();
                                        // 规格值加载
                                        if (res.data.spec_value_option) $('#spec_value_'+spec_mark_id).empty().html(res.data.spec_value_option);
                                        // 如果存在则执行覆盖新的规格列表框
                                        if (res.data.htmlTable) {
                                            // 加载规格框架
                                            $('#SpecTempLateDiv').html(res.data.htmlTable);
                                            // 合并单元格
                                            MergeCells();
                                        }
                                    }
                                });
                            }

                            // 批量设置价格
                            function BulkSetPrice(obj) {
                                layer.prompt({
                                    title: false, 
                                    shade: layer_shade,
                                    formType: 3,
                                    id: 'BulkSetPrice',
                                    btn: ['确定', '关闭'],
                                    closeBtn: 0,
                                    success: function(layero, index){
                                        $("#BulkSetPrice").find('input').attr('placeholder', '批量设置价格');
                                        $("#BulkSetPrice").find('input').attr('onkeyup', "this.value=this.value.replace(/[^\\d.]/g,'')");
                                        $("#BulkSetPrice").find('input').attr('onpaste', "this.value=this.value.replace(/[^\\d.]/g,'')");
                                    }
                                }, function(price, index){
                                    layer.close(index);
                                    // 规格中的价格
                                    $('.users_price').val(price);
                                    // 产品价格
                                    $('#users_price').val(price);
                                });
                            }

                            // 更新价格，取出最小的值赋值到价格中
                            function UpPrice(obj) {
                                var UsersPriceArray = new Array();
                                $('.users_price').each(function(){
                                    UsersPriceArray.push($(this).val());
                                });
                                // 取出最小值
                                var MinValue = Math.min.apply(Math, UsersPriceArray);
                                $('#users_price').val(MinValue);
                            }

                            // 批量设置价格
                            function BulkSetStock(obj) {
                                layer.prompt({
                                    title: false, 
                                    shade: layer_shade,
                                    formType: 3,
                                    id: 'BulkSetStock',
                                    btn: ['确定', '关闭'],
                                    closeBtn: 0,
                                    success: function(layero, index){
                                        $("#BulkSetStock").find('input').attr('placeholder', '批量设置库存');
                                        $("#BulkSetStock").find('input').attr('onkeyup', "this.value=this.value.replace(/[^\\d.]/g,'')");
                                        $("#BulkSetStock").find('input').attr('onpaste', "this.value=this.value.replace(/[^\\d.]/g,'')");
                                    }
                                }, function(stock, index){
                                    layer.close(index);
                                    // 单个库存
                                    $('.stock_count').val(stock);
                                    $('.stock_count').attr('data-old_stock',stock);
                                    stock_count = Number($('.stock_count').length) * Number(stock);
                                    $('#stock_count').val(stock_count);
                                    // 禁用库存框
                                    $('#stock_count').attr('readonly','readonly');
                                });
                            }

                            // 更新库存量
                            function UpStock(obj) {
                                var stock_count = $('#stock_count').val();
                                var new_stock = $(obj).val();
                                var old_stock = $(obj).attr('data-old_stock');
                                $(obj).attr('data-old_stock',new_stock);
                                if (Number(old_stock) > Number(new_stock)) {
                                    new_stock   = Number(old_stock) - Number(new_stock);
                                    stock_count = Number(stock_count) - Number(new_stock);
                                }else{
                                    new_stock   = Number(new_stock) - Number(old_stock);
                                    stock_count = Number(stock_count) + Number(new_stock);
                                }
                                $('#stock_count').val(stock_count);
                                $('#stock_count').attr('readonly','readonly');
                            }

                            // 合并单元格
                            function MergeCells() {
                                var tab = document.getElementById("spec_input_tab");
                                var maxCol = 2, val, count, start; 
                                if (tab != null) {
                                    for (var col = maxCol - 1; col >= 0; col--) {
                                        count = 1;
                                        val = "";
                                        for (var i = 0; i < tab.rows.length; i++) {
                                            if (val == tab.rows[i].cells[col].innerHTML) {
                                                count++;
                                            } else {
                                                if (count > 1) { //合并
                                                    start = i - count;
                                                    tab.rows[start].cells[col].rowSpan = count;
                                                    for (var j = start + 1; j < i; j++) {
                                                        tab.rows[j].cells[col].style.display = "none";
                                                    }
                                                    count = 1;
                                                }
                                                val = tab.rows[i].cells[col].innerHTML;
                                            }
                                        }
                                        if (count > 1) { //合并，最后几行相同的情况下
                                            start = i - count;
                                            tab.rows[start].cells[col].rowSpan = count;
                                            for (var j = start + 1; j < i; j++) {
                                                tab.rows[j].cells[col].style.display = "none";
                                            }
                                        }
                                    }
                                }
                            }
                        </script>
                    {/if}
                    <!-- 产品价格属性 -->
                {/if}

                {include file="archives/get_field_addonextitem" /}
            </div>
            <!-- 常规信息 -->

            <!-- 产品参数 -->
            <div class="ncap-form-default tab_div_2" style="display: none;">
                <!-- <dl class="row">
                    <dt class="tit"> <label>参数类型</label> </dt>
                    <dd class="opt">
                        <label><input type="radio" name="param_type" value="1" checked="checked" onclick="paramType(1);">系统参数</label>
                        &nbsp;
                        <label><input type="radio" name="param_type" value="2" onclick="paramType(2);">自定义参数</label>
                    </dd>
                </dl> -->
                <dl class="row">
                    <dt class="tit"> <label>商品参数</label> </dt>
                    <dd class="opt">
                        <div id="system_param" style="display: block;">
                            <div class="selectPro_arg">
                                <select name="attrlist_id" id="attrlist_id" onchange="AttrListSelect(this);">
                                    <option value="0">请选择参数</option>
                                    {volist name="AttrList" id="vo"}
                                    <option value="{$vo.list_id}">{$vo.list_name}</option>
                                    {/volist}
                                </select>
                                &nbsp; &nbsp; &nbsp;
                                <a href="JavaScript:void(0);" id="addCustomParam" data-attr_id="{$maxAttrID}" onclick="addCustomParam(this);" class="ncap-btn ncap-btn-green">自定义参数</a>
                                <!-- <a href="JavaScript:void(0);" onclick="attrlistLayer(this)" style="font-size: 12px;padding-left: 10px;">[管理]</a> -->
                            </div>
                            <dl class="row">
                                <dt class="sort-e lh40 pl0 text-l10" style=" background: #f4f6f8;">排序</dt>
                                <dt class="tit lh40 pl5 text-l10" style=" background: #f4f6f8;"> 参数名称</dt>
                                <dd class="opt w350 lh40 text-l10" style=" background: #f4f6f8;">参数值</dd>
                            </dl>
                            <div id='AttrSelectName' style="margin: 1px;"></div>
                            <div id='customParam' style="margin: 1px;"></div>
                        </div>

                        <!-- <div id="custom_param" style="display: none;">
                            <div class="copybtn"><a class="ncap-btn ncap-btn-green" href="javascript:void(0);" onclick="addCustomParam();">新增</a></div><br>
                            <div class="itemInfo">
                                <table cellspacing="0" cellpadding="0" border="0" class="normTbe tabInfo">
                                    <thead>
                                        <tr>
                                            <th class="w350">参数名称</th>
                                            <th class="w350">参数值</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody class="tbody1" id="attr_tbody">
                                        <tr>
                                            <td class="w350"><input type="text" name="param_name[]"></td>
                                            <td class="w350"><input type="text" name="param_value[]"></td>
                                            <td> <a class="text_a" href="javascript:void(0);" onclick="delCustomParam(this);">删除</a> </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div> -->
                    </dd>
                </dl>
                <script type="text/javascript">
                    // 商品参数切换
                    // function paramType(param_type) {
                    //     if (1 == param_type) {
                    //         $('#system_param').show();
                    //         $('#custom_param').hide();
                    //     } else {
                    //         $('#system_param').hide();
                    //         $('#custom_param').show();
                    //     }
                    // }

                    // 添加自定义参数
                    function addCustomParam(obj) {
                        var maxAttrID = $(obj).attr('data-attr_id');

                        // 规格值HTML
                        var html = [
                            '<dl class="row">'+
                                '<dt class="sort-e pl0"> <input type="text" size="4" name="sort_order['+maxAttrID+']" placeholder="100"> </dt>'+
                                '<dt class="tit pl5"> <input type="text" size="10" name="attr_name['+maxAttrID+']" placeholder="输入参数名称"> </dt>'+
                                '<dd class="opt pl5">'+
                                    '<input type="text" size="40" name="attr_value['+maxAttrID+']" placeholder="输入参数值">'+
                                    '<a class="text_a" href="javascript:void(0);" onClick="delCustomParam(this);">&nbsp;&nbsp;删除</a>'+
                                '</dd>'+
                            '</dl>'
                            // '<tr>'+
                            //     '<td class="w350"><input type="text" name="param_name[]" /></td>'+
                            //     '<td class="w350"><input type="text" name="param_value[]" /></td>'+
                            //     '<td> <a class="text_a" href="javascript:void(0);" onClick="delCustomParam(this);">删除</a> </td>'+
                            // '</tr>'
                        ];
                        // 加载一个规格值 input
                        $('#customParam').append(html);

                        // 自定义参数数量+1覆盖原值
                        $(obj).attr('data-attr_id', ++maxAttrID);
                    }

                    // 删除自定义参数
                    function delCustomParam(obj) {
                        $(obj).parent().parent().remove();
                        // var length = $("#attr_tbody>tr").length;
                        // if (parseInt(length) <= 1) {
                        //     showErrorMsg("至少保留一行");
                        // } else {
                        //     $(obj).parent().parent().remove();
                        // }
                    }

                    // 参数选择
                    function AttrListSelect(obj) {
                        var aid = '';
                        var list_id = $(obj).val();
                        if (parseInt(list_id) < 1) {
                            $("#AttrSelectName").empty();
                            return false;
                        }
                        $('#AttrSelectName').html('<div style="color: red;font-size: 12px;text-align: center;">加载中……</div>');
                        // 商品栏目切换时 ajax 调用  返回不同的属性输入框     
                        $.ajax({
                            type:'GET',
                            data:{aid:aid, list_id:list_id, _ajax:1}, 
                            url :"{:url('ShopProduct/ajax_get_shop_attr_input')}",
                            success:function(data) {
                                $("#AttrSelectName").empty().append(data);
                            }
                        });
                    }

                    function attrlistLayer(obj) {
                        var url = "{:url('ShopProduct/attrlist_index', ['oldinlet'=>1])}";
                        //iframe窗
                        layer.open({
                            type: 2,
                            title: '商品参数管理',
                            fixed: true, //不固定
                            shadeClose: false,
                            shade: layer_shade,
                            area: ['100%', '100%'],
                            content: url,
                            end: function(index){
                                var list_id = $('#attrlist_id').val();
                                $.ajax({
                                    url:"{:url('Product/ajax_get_shop_attrlist')}",
                                    type:'GET',
                                    data:{list_id:list_id, _ajax:1},
                                    success:function(res) {
                                        var html = "<option value='0'>请选择参数</option>";
                                        html += res;
                                        $("#attrlist_id").empty().append(html);

                                        // 删掉选中的参数之后，默认不选中，参数属性同时要清空掉
                                        if ($('#attrlist_id').val() < 1) {
                                            $("#AttrSelectName").empty();
                                        }
                                    },
                                    error: function(e){
                                        showErrorAlert(e.responseText);
                                    }
                                });
                            }
                        });
                        layer.full(iframes);
                    }
                </script>
            </div>
            <!-- 产品参数 -->

            <!-- SEO设置 -->
            <div class="ncap-form-default tab_div_3" style="display:none;">
                <dl class="row">
                    <dt class="tit"> <label for="seo_title">SEO标题</label> </dt>
                    <dd class="opt">
                        <input type="text" name="seo_title" id="seo_title" class="input-txt">
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label for="seo_keywords">SEO关键词</label> </dt>
                    <dd class="opt">
                        <textarea rows="5" cols="60" id="seo_keywords" name="seo_keywords" style="height: 40px;"></textarea>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label for="seo_description">SEO描述</label> </dt>
                    <dd class="opt">
                        <textarea rows="5" cols="60" id="seo_description" name="seo_description" style="height: 60px;"></textarea>
                    </dd>
                </dl>
            </div>
            <!-- SEO设置 -->

            <!-- 其他参数 -->
            <div class="ncap-form-default tab_div_4" style="display:none;">
                <dl class="row">
                    <dt class="tit"> <label for="author">作者</label> </dt>
                    <dd class="opt">
                        <input type="text" value="{$Think.session.admin_info.pen_name|default='小编'}" name="author" id="author" class="input-txt">
                    </dd>
                </dl>
                <dl class="row dl_origin">
                    <dt class="tit"> <label for="origin">来源</label> </dt>
                    <dd class="opt origin-hot">
                        <input type="text" value="{$system_originlist_0}" name="origin" id="origin" class="input-txt" onclick="searchOrigin(this);" autocomplete="off">
                        <div class="origin-hot-list" style="display: none;" id="search_keywords_list_origin"></div>
                        <textarea id="system_originlist_str" style="display: none;">{$system_originlist_str}</textarea>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label for="click">点击数</label> </dt>
                    <dd class="opt"> <input type="text" value="{$rand_arcclick}" name="click" id="click" class="input-txt"> </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label>阅读权限</label> </dt>
                    <dd class="opt">
                        <select name="arcrank" id="arcrank">
                            {volist name="arcrank_list" id="vo"}
                            <option value="{$vo.rank}">{$vo.name}</option>
                            {/volist}
                        </select>
                    </dd>
                </dl>
                <!-- #weapp_UsersGroup_content_users_id={$field.users_id}#--><!-- #weapp_UsersGroup_content# -->
                <dl class="row">
                    <dt class="tit"> <label for="add_time">发布时间</label> </dt>
                    <dd class="opt">
                        <input type="text" class="input-txt" id="add_time" name="add_time" value="{php}echo date('Y-m-d H:i:s'){/php}" autocomplete="off">
                        <span class="add-on input-group-addon"> <i class="glyphicon glyphicon-calendar fa fa-calendar"></i> </span>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label for="tempview">商品模板</label> </dt>
                    <dd class="opt">
                        <select name="tempview" id="tempview">
                            {volist name='$templateList' id='vo'}
                            <option value="{$vo}" {eq name='$vo' value='$tempview'}selected{/eq}>{$vo}</option>
                            {/volist}
                        </select>
                        <input type="hidden" name="type_tempview" value="{$tempview}" />
                    </dd>
                </dl>
                <dl class="row {notin name='$seo_pseudo' value='2'}no-grey{/notin}">
                    <dt class="tit"> <label for="htmlfilename">自定义文件名</label> </dt>
                    <dd class="opt">
                        <input type="text" {notin name='$seo_pseudo' value='2'}readonly="readonly" title="仅在静态模式下使用"{/notin} value="" name="htmlfilename" id="htmlfilename" autocomplete="off" onkeyup="this.value=this.value.replace(/[^\w\-]/g,'-');" onpaste="this.value=this.value.replace(/[^\w\-]/g,'-');" class="input-txt {notin name='$seo_pseudo' value='2'}no-drop{/notin}">.html
                    </dd>
                </dl>
            </div>
            <!-- 其他参数 -->
            
            <div class="ncap-form-default">
                <div class="bot2" style="left: 115px;">
                    <input type="hidden" name="gourl" value="{$gourl|default=''}">
                    <input type="hidden" id="editor_addonFieldExt" value="">
                    <a href="JavaScript:void(0);" onclick="check_submit();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
                    <a class="ncap-btn-big ncap-btn-no" href="javascript:history.back();" title="返回">返回</a>
                </div>
            </div> 
        </form>
    </div>
</div>

<script type="text/javascript">
    try{
        if (typeof(eval('is_conceal_1649209614'))=="function" && is_conceal_1649209614()){
            $(".page").css("margin-left","");
            $(".page").css("min-width","");
        }else{
            $(".page").css("margin-left","115px");
            $(".page").css("min-width","auto");
        }
    }catch(e){}

    layui.use('laydate', function() {
        var laydate = layui.laydate;

        laydate.render({
            elem: '#add_time'
            ,type: 'datetime'
        });
    })

    $(function () {
        try {
            var web_citysite_open = {$global['web_citysite_open']|default=0};
            var site_province_id = {$site_province_id|default=0};
            var site_city_id = {$site_city_id|default=0};
            var site_area_id = {$site_area_id|default=0};
            if (web_citysite_open > 0 && site_province_id > 0) {
                $('select[name=province_id]').val(site_province_id);
                set_city_list(site_city_id);
                set_area_list(site_area_id);
            }
        }catch(e){}
     
        //选项卡切换列表
        $('.tab-base').find('.tab').click(function(){
            $('.tab-base').find('.tab').each(function(){
                $(this).removeClass('current');
            });
            $(this).addClass('current');
            var tab_index = $(this).data('index');          
            $(".tab_div_1, .tab_div_2, .tab_div_3, .tab_div_4").hide();          
            $(".tab_div_"+tab_index).show();
            layer.closeAll();
        });

        $('input[name=is_jump]').click(function(){
            if ($(this).is(':checked')) {
                $('.dl_jump').show();
            } else {
                $('.dl_jump').hide();
            }
        });

        var dftypeid = {$typeid|default='0'};
        $('#typeid').change(function(){
            var current_channel = $(this).find('option:selected').data('current_channel');
            if (0 < $(this).val() && {$channeltype} != current_channel) {
                showErrorMsg('请选择对应模型的栏目！');
                $(this).val(dftypeid);
            } else if ({$channeltype} == current_channel) {
                layer.closeAll();
            }
            GetAddonextitem(1, $(this).val(), {$channeltype}, 0, true);
        });

        $(document).click(function(){
            $('#often_tags').hide();
            $('#often_tags_input').hide();
            event.stopPropagation();
        });

        $('#often_tags').click(function(){
            $('#often_tags').show();
            event.stopPropagation();
        });

        $('input[name=tags]').keyup(function(){
            var tags = $.trim($(this).val());
            $('#seo_keywords').val(tags);
        });
    });
    
    function change_prom_type(val) {
        if ( val == 1 ){
            $("input[name=prom_type_vir]:eq(0)").attr("checked",'checked');
            $("#fahuoxingshi").show();
        } else if ( val == 2 ){
            $("#wangpanxiazai").hide();
            $("#wenbenneirong").hide();
        } else if ( val == 3 ){
            $("#wangpanxiazai").show();
            $("#wenbenneirong").hide();
        } else if( val == 4 ){
            $("#wangpanxiazai").hide();
            $("#wenbenneirong").show();
        }
        else {
            $("#wangpanxiazai").hide();
            $("#wenbenneirong").hide();
            $("#fahuoxingshi").hide();
        }
    }

    // 判断输入框是否为空
    function check_submit(){
        if($.trim($('input[name=title]').val()) == ''){
            showErrorMsg('标题不能为空！');
            $($('.tab-base').find('.tab')[0]).trigger('click'); 
            $('input[name=title]').focus();
            return false;
        }
        if ($('#typeid').val() == 0) {
            showErrorMsg('请选择栏目…！');
            $($('.tab-base').find('.tab')[0]).trigger('click'); 
            $('#typeid').focus();
            return false;
        }
        if ($('input[name=prom_type]:checked').val() == 1) {
            if($('input[name=prom_type_vir]:checked').val() == 2 && $.trim($('input[name=netdisk_url]').val()) == ''){
                showErrorMsg('网盘地址不能为空！');
                $($('.tab-base').find('.tab')[0]).trigger('click'); 
                $('input[name=netdisk_url]').focus();
                return false;
            }
            if($('input[name=prom_type_vir]:checked').val() == 3 && $.trim($('textarea[name=text_content]').val()) == ''){
                showErrorMsg('虚拟文本内容不能为空！');
                $($('.tab-base').find('.tab')[0]).trigger('click'); 
                $('textarea[name=text_content]').focus();
                return false;
            }
        }
        
        layer_loading('正在处理');
        if(!ajax_check_htmlfilename())
        {
            layer.closeAll();
            showErrorMsg('自定义文件名已存在！');
            $('input[name=htmlfilename]').focus();
            return false;
        }
        setTimeout(function (){
            editor_auto_210607();
            $('#post_form').submit();
        }, 1);
    }

    function img_call_back(fileurl_tmp)
    {
        $("#litpic_local").val(fileurl_tmp);
        $("#img_a").attr('href', fileurl_tmp);
        $("#img_i").attr('onmouseover', "layer_tips=layer.tips('<img src="+fileurl_tmp+" class=\\'layer_tips_img\\'>',this,{tips: [1, '#fff']});");
        $("input[name=is_litpic]").attr('checked', true); // 自动勾选属性[图片]
    }

    // 上传产品相册回调函数
    function proimg_call_back(paths){
        var  last_div = $(".images_upload_tpl").html();
        for (var i=0;i<paths.length ;i++ )
        {
            if ($(".sort-list-img .images_upload_html").length > 0) {
                $(".sort-list-img .images_upload_html:last").after(last_div);  // 插入一个 新图片
            } else {
                $(".sort-list-img .images_upload:last").before(last_div);  // 插入一个 新图片
            }
            $(".sort-list-img .images_upload_html:last").find('a:eq(0)').attr('href',paths[i]).attr('onclick','').attr('target', "_blank");// 修改他的链接地址
            $(".sort-list-img .images_upload_html:last").find('img').attr('src',paths[i]);// 修改他的图片路径
            $(".sort-list-img .images_upload_html:last").find('a:eq(1)').attr('onclick',"ClearPicArr2(this,'"+paths[i]+"')").text('');
            $(".sort-list-img .images_upload_html:last").find('input').val(paths[i]); // 设置隐藏域 要提交的值
        }             
    }
    /*
     * 上传之后删除组图input     
     * @access   public
     * @val      string  删除的图片input
     */
    function ClearPicArr2(obj,path)
    {
        $(obj).parent().parent().remove(); // 删除完服务器的, 再删除 html上的图片
        $.ajax({
            type:'POST',
            url:"{:url('Uploadimgnew/delupload')}",
            data:{action:"del", filename:path,_ajax:1},
            success:function(){}
        });
    }


    /** 以下 产品参数相关 js*/
    $(document).ready(function(){
        // 产品栏目切换时 ajax 调用  返回不同的属性输入框
        $("#typeid").change(function(){
            get_attr_input();
        });
        // 触发产品栏目
        // $("#typeid").trigger('change'); 
    });

    // 产品栏目切换时 ajax 调用  返回不同的参数输入框
    function get_attr_input()
    {
        var aid = '';
        var typeid = $("#typeid").val();
        if (parseInt(typeid) < 1) {
            return false;
        }
        $('#product_attr_table').html('<div style="color: red;font-size: 12px;text-align: center;">加载中……</div>');
        // 产品栏目切换时 ajax 调用  返回不同的属性输入框     
        $.ajax({
            type:'GET',
            data:{aid:aid,typeid:typeid,_ajax:1}, 
            url:"{:url('Product/ajax_get_attr_input')}",
            success:function(data){
                $("#product_attr_table").html('').append(data);
            },
            error: function(e){
                $('#product_attr_table').html('<div style="color: red;font-size: 12px;text-align: center;">加载失败，点击此处<a href="javascript:void(0);" onClick="get_attr_input();">刷新</a></div>');
            }
       });
    }

    /** 以下 产品相册的拖动排序相关 js*/

    $( ".sort-list-img" ).sortable({
        start: function( event, ui) {
        
        }
        ,stop: function( event, ui ) {
        }
    });
    //因为他们要拖动，所以尽量设置他们的文字不能选择。 
    $( ".sort-list-img" ).disableSelection();
</script>
<script>
    try{
        var mt20_1649209614 = sessionStorage.getItem("mt20_1649209614");
        if (mt20_1649209614 == 1){
            $("#geduan_div").removeClass("h15");
        }else{
            $("#geduan_div").addClass("h15");
        }
    }catch(e){}
</script>
{include file="public/footer" /}